package flst.ipiweb.process;

import java.util.List;

import flst.ipiweb.persistance.FactoryDAL;
import flst.ipiweb.transverse.Article;
import flst.ipiweb.transverse.IPIWebException;

public class ArticleProcess {

	public List<Article> getAllArticle() throws IPIWebException{
		return FactoryDAL.getInstance().getArticleDAL().getAllArticle();
	}
	
	public Article getArticleById(int id) throws IPIWebException{
		return FactoryDAL.getInstance().getArticleDAL().getArticleById(id);
	}
	
	public void CreateArticle(Article art) throws IPIWebException{
		FactoryDAL.getInstance().getArticleDAL().createArticle(art);
	}
	
	public void UpdateArticle(Article art) throws IPIWebException{
		FactoryDAL.getInstance().getArticleDAL().UpdateArticle(art);
	}
	
	public void DesactiverArticle(int id) throws IPIWebException{
		FactoryDAL.getInstance().getArticleDAL().DesativerArticle(id);
	}
	
	public int GenerateId() throws IPIWebException{
		return FactoryDAL.getInstance().getArticleDAL().GenerateId();
	}
	
	public Boolean checkArticleById(int id) throws IPIWebException{
		Article art = FactoryDAL.getInstance().getArticleDAL().getArticleActifById(id);
		if (art!=null && art.getId()>0){
			return true;
		}
		else{
			return false;
		}
	}
}
